using System;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel;
using System.Collections.Generic;

using TD.SandDock;

using SBPweb.Themes.Windows;
using SBPweb.Themes.Windows.Skins;
using System.Xml;


namespace SBPweb.Controls.Windows.Docking
{
	public class DockableWindow : TD.SandDock.DockableWindow, SBPweb.Themes.Windows.Skins.ISkinnable
	{
		private bool mUseDefaultSkin;
		private Skin mSkin;
		private bool mUseThisBackgrounColorOnChildControls = true;

		public bool UseThisBackgrounColorOnChildControls
		{
			get { return mUseThisBackgrounColorOnChildControls; }
			set { mUseThisBackgrounColorOnChildControls = value; }
		}

		public DockableWindow()
			: base()
		{
		}

		public DockableWindow(SandDockManager manager, Control control, string text) : base(manager, control, text)
		{
		}

		protected override void OnPaintBackground(PaintEventArgs e)
		{
			
			if (Skin != null)
			{
				this.BackColor = Skin.CachedProperties.FormBackColor;
				if (mUseThisBackgrounColorOnChildControls)
					foreach (Control c in this.Controls)
					{
						c.BackColor = Skin.CachedProperties.FormBackColor;
					}
			}
			base.OnPaintBackground(e);

		}

		#region ISkinnable Members

		/// <summary>
		/// Use default skin?
		/// </summary>
		[Category("Look && feel")]
		public bool UseDefaultSkin
		{
			get
			{
				return mUseDefaultSkin;
			}
			set
			{
				mUseDefaultSkin = value;
				Invalidate();
			}
		}

		/// <summary>
		/// Used skin
		/// </summary>
		[Category("Look && feel")]
		public Skin Skin
		{
			get
			{
				if (this.UseDefaultSkin)
				{
					return DefaultLookAndFeel.Skin;
				}

				return mSkin;
			}
			set
			{
				mSkin = value;
				Invalidate();
			}
		}

		#endregion


	}
}
